package com.as.server.entity;

import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 
 * @TableName like
 */
@Data
@NoArgsConstructor

public class Like implements Serializable,Comparable<Like> {
    /**
     * 
     */
    private Integer lid;

    /**
     * 
     */
    private Long uid;

    /**
     * 
     */
    private Long aid;

    /**
     * 
     */
    private Integer score;

    /**
     * 
     */
    private Date time;

    private Article article;

    private static final long serialVersionUID = 1L;

    public Like(Long aid, Integer score) {
        this.aid = aid;
        this.score = score;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Like other = (Like) that;
        return (this.getLid() == null ? other.getLid() == null : this.getLid().equals(other.getLid()))
            && (this.getUid() == null ? other.getUid() == null : this.getUid().equals(other.getUid()))
            && (this.getAid() == null ? other.getAid() == null : this.getAid().equals(other.getAid()))
            && (this.getScore() == null ? other.getScore() == null : this.getScore().equals(other.getScore()))
            && (this.getTime() == null ? other.getTime() == null : this.getTime().equals(other.getTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getLid() == null) ? 0 : getLid().hashCode());
        result = prime * result + ((getUid() == null) ? 0 : getUid().hashCode());
        result = prime * result + ((getAid() == null) ? 0 : getAid().hashCode());
        result = prime * result + ((getScore() == null) ? 0 : getScore().hashCode());
        result = prime * result + ((getTime() == null) ? 0 : getTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "Like{" +
                "lid=" + lid +
                ", uid=" + uid +
                ", aid=" + aid +
                ", score=" + score +
                ", time=" + time +
                ", article=" + article +
                '}';
    }

    @Override
    public int compareTo(Like o) {
        return  score > o.getScore() ? -1 : 1;
    }
}